home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Freeware / DiskMaster / Rexx / DMDirLevel.rexx < prev    next >
OS/2 REXX Batch file  |  2002-10-27  |  2KB  |  75 lines

  1. /* $VER: DMDirLevel.rexx 1.0 (30.3.98) by J. Tierney
  2.  
  3.   DiskMaster II Directory Level  v1.0
  4.   3/30/98  J. Tierney <jtierney@cyberlink-inc.com>
  5.  
  6.   Purpose:  Jumps to a directory level.
  7.  
  8.   Usage:  Rexx DMDirLevel.rexx <window S|D|N> [<level>]
  9.  
  10.           <window> - Window to display the directory in:
  11.                      S = Source.
  12.                      D = Destination.
  13.                      N = New window.
  14.  
  15.           <level>  - Directory level to jump to.  0 = root.
  16.                     If not specified, a requester will pop up asking for the
  17.                     level.
  18.  
  19.   Example:
  20.     Current path = "Games:PAL_Games/Worms/TWCUSTOM"
  21.     Dir. level 0 = "Games:"
  22.     Dir. level 1 = "Games:PAL_Games"
  23.     Dir. level 9 = "Games:PAL_Games/Worms/TWCUSTOM" (No change.)
  24. */
  25.  
  26. /* Dimensions for the new window. */
  27. /* Change these to suit yourself. */
  28. winx = 100  /* X      */
  29. winy = 8    /* Y      */
  30. winw = 260  /* Width  */
  31. winh = 194  /* Height */
  32.  
  33. OPTIONS RESULTS
  34.  
  35. ARG dest lvl
  36. IF lvl = '' THEN DO
  37.   'CONFIRM "Dir. level (0 = Root):", Okay Cancel 1'
  38.   IF rc = 1 THEN EXIT 0
  39.   lvl = STRIP(result, 'B')
  40. END
  41.  
  42. IF dest = '' THEN dest = 'S'
  43. ELSE dest = LEFT(dest, 1)
  44.  
  45. 'STATUS P'
  46. path = result
  47. IF RIGHT(path, 1) ~= ':' THEN path = path || '/'
  48. pathlen = LENGTH(path)
  49.  
  50. IF lvl = 0 THEN DO
  51.   x = POS(':', path)
  52.   IF x > 0 THEN newpath = LEFT(path, x)
  53.   END
  54. ELSE DO
  55.   fx = 0
  56.   DO UNTIL  lvl = 0
  57.     x = POS('/', path, fx + 1)
  58.     IF x > 0 THEN DO
  59.       fx = x
  60.       lvl = lvl - 1
  61.       END
  62.     ELSE lvl = 0
  63.   END
  64.   IF fx > 0 THEN newpath = LEFT(path, fx)
  65. END
  66.  
  67. IF (dest = 'S') & (newpath = path) THEN EXIT 0
  68. IF dest = 'N' THEN DO
  69.   'OPENWINDOW' winx winy winw winh newpath
  70.   EXIT 0
  71. END
  72. IF (dest = 'D') THEN 'WINDOW DEST'
  73. 'NEWDIR' newpath
  74. IF dest ~= 'S' THEN 'WINDOW DEST'
  75.